package com.xusheng.cli.core.task;

import com.xusheng.cli.mapper.ExceptionLogMapper;
import com.xusheng.cli.mapper.OperationLogMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author jy
 * @since 2020-10-25 01:47
 */
@Component
@Slf4j
public class RemoveLogsTask {

    @Autowired
    private OperationLogMapper operationLogMapper;

    @Autowired
    private ExceptionLogMapper exceptionLogMapper;

    /**
     * 每周一 凌晨删除 一周前的日志信息
     *
     * @author jy
     * @since 2020/10/25 2:03
     */
    @Async("taskExecutor")
//	@Scheduled(cron = "10 * * * * ? ")
    @Scheduled(cron = "0 0 0 * * ? ")
    public void deleteLogsFrom1WeekAgo() {
        operationLogMapper.deleteDataFrom1WeekAgo();
        exceptionLogMapper.deleteDataFrom1WeekAgo();
        log.info("执行定时任务:deleteLogsFrom1WeekAgo");
    }

}
